home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- ''' Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) '''
- from import fixer_base
- from fixer_util import BlankLine
-
- class FixItertoolsImports(fixer_base.BaseFix):
- PATTERN = "\n import_from< 'from' 'itertools' 'import' imports=any >\n " % locals()
-
- def transform(self, node, results):
- imports = results['imports']
- if not imports.children[:]:
- pass
- children = [
- imports]
- for child in children:
- if not hasattr(child, 'value'):
- continue
-
- if child.value in ('imap', 'izip', 'ifilter'):
- child.value = None
- child.remove()
- continue
- if child.value == 'ifilterfalse':
- node.changed()
- child.value = 'filterfalse'
- continue
-
- if not imports.children[:]:
- pass
- children = [
- imports]
- remove_comma = True
- for child in children:
- if remove_comma and getattr(child, 'value', None) == ',':
- child.remove()
- continue
- remove_comma ^= True
-
- if unicode(children[-1]) == ',':
- children[-1].remove()
-
- if not imports.children or getattr(imports, 'value', None):
- p = node.get_prefix()
- node = BlankLine()
- node.prefix = p
-
- return node
-
-
-